

Ext.namespace('pacp');


pacp.selectwindow = new Ext.extend(Ext.Window, {
    title: 'Select Atlas Maps',
    collapsible: false,
    maximizable: true,
    singleSelect: false,
    width: 300,
    height: 300,
    minWidth: 300,
    minHeight: 200,
    closeAction: 'hide',
    modal: true,
    columns: [],
    hideHeaders: false,
    
    layout: 'fit',
    selectorLabel: 'Atlas',
    plain: true,
    //bodyStyle: 'padding:5px;',
    buttonAlign: 'center',
    //    renderTo: 'itemselector',
    initComponent: function(){
        this.items = this.buildWindow();//item selector form
        this.buttons = [this.buildButtons()];
        this.store.load();
        pacp.selectwindow.superclass.initComponent.apply(this, arguments);
        //add custom event
        this.addEvents({
            submitselection: true
        })
    },
    //	onRender: function(){
    //		pacp.multiselect.superclass.onRender.apply(this, arguments);
    //	},
    store: ds,
    
    buildWindow: function(){
        var listView = new Ext.list.ListView({
            store: this.store,
            multiSelect: this.singleSelect == false,
            simpleSelect: this.singleSelect == false,
            singleSelect: this.singleSelect,
            name: 'itemselector',
            hideHeaders: this.hideHeaders,
            emptyText: 'No item to display',
            reserveScrollOffset: true,
            columns: this.columns
        });
        this.isForm = listView;
        var isForm = new Ext.form.FormPanel({
            title: '',
            width: this.width,
            items: listView,
            layout: 'fit'
        
        });
        return isForm
        
        
    },
    
    buildButtons: function(){
        return new Ext.Button({
            text: 'OK',
            handler: function(){
                var values = [];
                Ext.each(this.isForm.getSelectedRecords(), function(r, index){
                    values.push([r.get('value')])
                });
                
                this.hide();
                //fire event
                this.fireEvent('submitselection', values, this)
                
                
            },
            scope: this
        })
    }
    
});





